package com.ftf.tp.blog.interfaces.facade.rpc;

import com.ftf.tp.blog.client.dto.ArticleDTO;
import com.ftf.tp.blog.client.facade.rpc.ArticleRpcFacade;
import com.ftf.tp.blog.domain.article.dos.ArticleDO;
import com.ftf.tp.blog.domain.article.repository.ArticleRepository;
import com.ftf.tp.common.core.utils.ConverterUtil;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;

/**
 * @author tanghao
 * @date 2022/9/2
 */
@DubboService(version = "1.0.0", interfaceClass = ArticleRpcFacade.class)
public class ArticleRpcFacadeImpl implements ArticleRpcFacade {

    @Resource
    private ArticleRepository articleRepository;

    @Override
    public ArticleDTO getArticleById(Long id) {
        ArticleDO articleDO = articleRepository.byId(id);
        ArticleDTO articleDTO = new ArticleDTO();
        ConverterUtil.copyPropertiesIgnoreNull(articleDO, articleDTO);
        return articleDTO;
    }
}
